# coding:utf-8
# Funny (qq:516110288)

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import pymysql
from sqlalchemy import create_engine
from pandas.io.sql import read_sql

df = pd.DataFrame(data=np.random.randint(60, 100, (4, 3)), index=['第%s行' % i for i in range(1, 5)],columns=['第%s列' % j for j in range(1,4)])
print(df)
engine = create_engine("mysql+pymysql://root:kjl123.0@localhost:3306/db3?charset=utf8", echo=False)
df.to_sql(name="score", con=engine, if_exists="append",index=True)
# try:
#     db = pymysql.connect(host='127.0.0.1',port=3306,user='root',password ='kjl123.0',db='db3',charset="utf-8")
#     corsor=conn.cursor()
#     sql = "insert into student(id,name,age,sex,kk ) values(1,ba,"难"，12,11)"
#     df_score = read_sql(query, db)
# except Exception as e
#     print(e)
# print(df_score)

# db = pymysql.connect("localhost", "root", "kjl123.0", "db3", charset='utf8')
# query = "SELECT 第1列,第2列,第3列 from score"
# df_score = read_sql(query, db)
# print(df_score)